<?
function thumb($src,$dest)
{
  $source_image = imagecreatefromjpeg($src);
  $width = imagesx($source_image);
  $height = imagesy($source_image);
  $desired_height = "500" ;
  $desired_width =  floor($width*($desired_height/$height));
  $virtual_image = imagecreatetruecolor($desired_width,$desired_height);
  imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
  imagejpeg($virtual_image,$dest);

}
